import os
import re

def delete_homework_files(directory="."):
    pattern = re.compile(r"^\d{8}作业\.md$")
    deleted = []

    for filename in os.listdir(directory):
        if pattern.match(filename):
            file_path = os.path.join(directory, filename)
            try:
                os.remove(file_path)
                deleted.append(filename)
            except Exception as e:
                print(f"❌ 删除 {filename} 失败: {e}")

    if deleted:
        print("✅ 已删除以下作业文件：")
        for f in deleted:
            print(f"  - {f}")
    else:
        print("ℹ️ 没有找到符合条件的作业文件。")

if __name__ == "__main__":
    delete_homework_files(".")
